﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/AdminInfo/Views/Shared/_LayoutPage1.cshtml";
}
@model Gtkj.CMS.Model.AutoInfo
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">

                <form id="form1" class="layui-form layui-form-pane" data-render="true">
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="Title" value="@(Model==null?"": Model.Title)" required jq-verify="required" jq-error="请输入标题" placeholder="请输入标题" autocomplete="off" class="layui-input ">
                        </div>
                    </div>
                    <div class="layui-form-item ">
                        <label class="layui-form-label">内容</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor">@(Model == null ? null : Html.Raw(Model.Contents))</textarea>
                            @*<textarea name="content" id="conntent" style="display:none;">@(Model == null ? "": Model.Contentxt)</textarea>*@
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                            @if (Model == null)
                            {
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            }
                        </div>
                    </div>
                    <input type="hidden" name="ID" value="@(Model==null?"":Model.ID.ToString())" />
                </form>
            </section>
        </div>
    </div>
</div>
<script>
    var $;
    //var $Type = $("Type");
    layui.use(['form', 'upload', 'layedit', 'jqform'], function () {
        var editIndex;
        $ = layui.jquery,
            jqform=layui.jqform,
         form = layui.form(), layedit = layui.layedit;
        //创建一个编辑器
        layedit.set({
            uploadImage: {
                url: '/Upload/RichTextUploadImage' //接口url
              , type: 'post' //默认post
            }
        });
        editIndex = layedit.build('LAY_demo_editor');
        

        form.on('submit(sub)', function (data) {
            //layedit.getContent(index)
            data.field[$("#LAY_demo_editor").attr("name")] = layedit.getContent(editIndex);
            //$('#LAY_demo_editor').val(layedit.getContent(editIndex));
            $.post('/AdminInfo/AdminAutoPage/InfoUP', data.field, function (r) {
                if (r.status == 200) {
                    layer.msg(r.message);
                } else {
                    layer.msg(r.message);
                }
            });
            return false;
        });
        
    });
</script>